package com.handpay.nocardpay.baselibrary.config;

/**
 * Created by fplei on 2017/8/9.<br/>
 * the role of a bridge with class and jni<br/>
 * ps:because this method is static,so this class not allow to use class of HPLog that not static.<br/>
 */

public class NativeEngine {
    public static final String TAG = "NativeEngine";

    static {
        System.loadLibrary("native-lib");
    }

    public native static String[] loadResources();

    //this function use to loadNative source
    public static NativeObject initNativeLib() {
        String[] tempResources = loadResources();
        NativeObject nativeObject = new NativeObject();
        if (tempResources != null) {
            nativeObject.setAppServer(tempResources[0]);
            nativeObject.setChannel(tempResources[1]);
            nativeObject.setHPVersion(tempResources[2]);
            nativeObject.setDomain(tempResources[3]);
            nativeObject.setClientChannel(tempResources[4]);
            nativeObject.setModulus(tempResources[5]);
            nativeObject.setExponent(tempResources[6]);
            nativeObject.setLocalKeyModulus(tempResources[7]);
            nativeObject.setHelperCenterUrl(tempResources[8]);
            nativeObject.setRegistation(tempResources[9]);
            nativeObject.setAdvertUrl(tempResources[10]);
            nativeObject.setSmartPayUrl(tempResources[11]);
            nativeObject.setSmartPay3DesKey(tempResources[12]);
            nativeObject.setOnlineMarketUrl(tempResources[13]);
            nativeObject.setRainDropsUrl(tempResources[14]);
            nativeObject.setP12Key(tempResources[15]);
        }
        return nativeObject;
    }

    static class NativeObject {
        /**
         * api接口地址
         */
        private String AppServer;
        /**
         * 服务器域名
         */
        private String Domain;
        /**
         * 渠道号
         */
        private String Channel;
        /**
         * 协议版本号
         */
        private String HPVersion;
        /**
         * 客户端渠道号（预留）updateChinnel 版本更新也使用它
         */
        private String ClientChannel;
        /**
         * rsa公钥系数(模数)
         */
        private String Modulus;
        /**
         * rsa公钥指数
         */
        private String Exponent;
        /**
         * 本地数据加密常量
         */
        private String LocalKeyModulus;
        /**
         * 帮助文档
         */
        private String helperCenterUrl;
        /**
         * 注册协议
         */
        private String registation;
        /**
         * 广告页地址
         */
        private String advertUrl;
        /**
         * 代还款URL
         */
        private String smartPayUrl;
        /**
         * 代还款3deskey
         */
        private String smartPay3DesKey;
        /**
         * 在线商城
         */
        private String onlineMarketUrl;

        /**
         * 小雨点外放对接接口
         */
        private String rainDropsUrl;
        /**
         * 证书 p12key
         */
        private String p12Key;

        public String getSmartPay3DesKey() {
            return smartPay3DesKey;
        }

        public void setSmartPay3DesKey(String smartPay3DesKey) {
            this.smartPay3DesKey = smartPay3DesKey;
        }

        public String getAppServer() {
            return AppServer;
        }

        public void setAppServer(String appServer) {
            AppServer = appServer;
        }

        public String getDomain() {
            return Domain;
        }

        public void setDomain(String domain) {
            Domain = domain;
        }

        public String getChannel() {
            return Channel;
        }

        public void setChannel(String channel) {
            Channel = channel;
        }

        public String getHPVersion() {
            return HPVersion;
        }

        public void setHPVersion(String HPVersion) {
            this.HPVersion = HPVersion;
        }

        public String getClientChannel() {
            return ClientChannel;
        }

        public void setClientChannel(String clientChannel) {
            ClientChannel = clientChannel;
        }

        public String getModulus() {
            return Modulus;
        }

        public void setModulus(String modulus) {
            Modulus = modulus;
        }

        public String getExponent() {
            return Exponent;
        }

        public void setExponent(String exponent) {
            Exponent = exponent;
        }

        public String getLocalKeyModulus() {
            return LocalKeyModulus;
        }

        public void setLocalKeyModulus(String localKeyModulus) {
            LocalKeyModulus = localKeyModulus;
        }

        public String getHelperCenterUrl() {
            return helperCenterUrl;
        }

        public void setHelperCenterUrl(String helperCenterUrl) {
            this.helperCenterUrl = helperCenterUrl;
        }

        public String getRegistation() {
            return registation;
        }

        public void setRegistation(String registation) {
            this.registation = registation;
        }

        public String getAdvertUrl() {
            return advertUrl;
        }

        public void setAdvertUrl(String advertUrl) {
            this.advertUrl = advertUrl;
        }

        public String getSmartPayUrl() {
            return smartPayUrl;
        }

        public void setSmartPayUrl(String smartPayUrl) {
            this.smartPayUrl = smartPayUrl;
        }

        public String getOnlineMarketUrl() {
            return onlineMarketUrl;
        }

        public void setOnlineMarketUrl(String onlineMarketUrl) {
            this.onlineMarketUrl = onlineMarketUrl;
        }

        public String getRainDropsUrl() {
            return rainDropsUrl;
        }

        public void setRainDropsUrl(String rainDropsUrl) {
            this.rainDropsUrl = rainDropsUrl;
        }

        public String getP12Key() {
            return p12Key;
        }

        public void setP12Key(String p12Key) {
            this.p12Key = p12Key;
        }

        @Override
        public String toString() {
            return "NativeObject{" +
                    "AppServer='" + AppServer + '\'' +
                    ", Domain='" + Domain + '\'' +
                    ", Channel='" + Channel + '\'' +
                    ", HPVersion='" + HPVersion + '\'' +
                    ", ClientChannel='" + ClientChannel + '\'' +
                    ", Modulus='" + Modulus + '\'' +
                    ", Exponent='" + Exponent + '\'' +
                    ", LocalKeyModulus='" + LocalKeyModulus + '\'' +
                    ", helperCenterUrl='" + helperCenterUrl + '\'' +
                    ", registation='" + registation + '\'' +
                    ", advertUrl='" + advertUrl + '\'' +
                    ", smartPayUrl='" + smartPayUrl + '\'' +
                    ", smartPay3DesKey='" + smartPay3DesKey + '\'' +
                    ", onlineMarketUrl='" + onlineMarketUrl + '\'' +
                    ", rainDropsUrl='" + rainDropsUrl + '\'' +
                    ", p12Key='" + p12Key + '\'' +
                    '}';
        }
    }
}
